package com.game.curator;


import java.util.Arrays;

public class ClusterHelper {
    public static boolean inIpWhiteList(String ip, String[] whiteList) {
        if (whiteList == null || whiteList.length == 0)
            return true;
        return Arrays.<String>asList(whiteList).contains(ip);
    }

    public static boolean preciseInIpWhiteList(String ip, String[] whiteList) {
        if (whiteList == null || whiteList.length == 0)
            return false;
        return Arrays.<String>asList(whiteList).contains(ip);
    }

    public static boolean inIdWhiteList(long id, int[] whiteList) {
        if (whiteList == null || whiteList.length == 0)
            return true;
        int[] arrayOfInt;
        int i;
        byte b;
        for (arrayOfInt = whiteList, i = arrayOfInt.length, b = 0; b < i; ) {
            long wid = arrayOfInt[b];
            if (wid == id)
                return true;
            b++;
        }
        return false;
    }

    public static boolean preciseInIdWhiteList(long id, int[] whiteList) {
        if (whiteList == null || whiteList.length == 0)
            return false;
        int[] arrayOfInt;
        int i;
        byte b;
        for (arrayOfInt = whiteList, i = arrayOfInt.length, b = 0; b < i; ) {
            long wid = arrayOfInt[b];
            if (wid == id)
                return true;
            b++;
        }
        return false;
    }
}
